package org.example.springioc.controller;

import jakarta.annotation.PostConstruct;
import org.example.springioc.config.StudentConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class PropertiesController {
    @Value("${my.key}")
    private String myKey;
    @Autowired
    public StudentConfig studentConfig;
    @PostConstruct
    public void readValue(){
        System.out.println(("从配置文件中读取配置信息" + myKey));
    }
    @RequestMapping("/readObject")
    public String readObject(){
        return studentConfig.toString();
    }
}
